﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

using ComLib.Data;
using ComLib.Web.Modules.Widgets;
using ComLib.Web.Lib.Controllers;


namespace ComLib.CMS.Controllers
{
    /// <summary>
    /// Controller for Dynamic Html content pages.
    /// </summary>
    [HandleError]
    public class WidgetController : EntityControllerAdmin<WidgetInstance>, IEntityController
    {
        /// <summary>
        /// OVerride the url to use after creation.
        /// </summary>
        protected override void Init()
        {
            Conf["CreateSuccessUrl"] = "manage";
            Conf["UpdateSuccessUrl"] = "manage";
        }


        /// <summary>
        /// This changes the controller name to be "widget" instead of "widgetinstance".
        /// </summary>
        /// <param name="view"></param>
        /// <param name="entity"></param>
        /// <param name="controlPath"></param>
        /// <param name="useForm"></param>
        protected override void BuildViewModel(ComLib.Web.Lib.Models.EntityBaseViewModel view, WidgetInstance entity, string controlPath, bool useForm)
        {
            base.BuildViewModel(view, entity, controlPath, useForm);
            view.Name = "widget";
        }
    }
}
